package com.songhq.data.kafka.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.annotation.PartitionOffset;
import org.springframework.kafka.annotation.TopicPartition;
import org.springframework.stereotype.Component;

@Component
public class KafkaConsumer {
	
	
	    //@KafkaListener 默认是从当前时间开始消费
	   // @KafkaListener(id = "foo", topics = "foo")
	    public void listen(String data) {
	       System.out.println("接收到消息" + data);
	    }
	    
	  
	   //@KafkaListener(id = "myContainer2",topicPartitions = { @TopicPartition(topic = "foo", partitions = { "0", "3" }),
      //         @TopicPartition(topic = "app_log", partitions = "0",
      //         partitionOffsets = @PartitionOffset(partition = "1", initialOffset = "0"))})
	    public void listen2(ConsumerRecord<?, ?> record){
	        System.out.println("topic：" + record.topic());
	        System.out.println("key:" + record.key());
	        System.out.println("value:"+record.value());
	    }
	
	

}
